<% @title = t(".api_key_role_name", name: @api_key_role.name) %>
<div class="t-body">
  <% if @api_key_role.github_actions_push? && !@api_key_role.deleted_at? %>
    <h2 class="t-display"><%= link_to t(".automate_gh_actions_publishing"), github_actions_workflow_profile_oidc_api_key_role_path(@api_key_role.token), class: "t-link t-underline" %> →</h2>
  <% end %>
  <% if @api_key_role.deleted_at? %>
    <h2 class="t-display">
      <%= t(".deleted_at_html", time_html:  time_tag(@api_key_role.deleted_at, time_ago_in_words(@api_key_role.deleted_at))) %>
    </h2>
  <% end %>
  <h3 class="t-list__heading"><%= OIDC::ApiKeyRole.human_attribute_name(:token) %></h3>
  <div class="push--s">
    <code><%= @api_key_role.token %></code>
  </div>
  <h3 class="t-list__heading"><%= OIDC::ApiKeyRole.human_attribute_name(:provider) %></h3>
  <div class="push--s">
    <%= link_to t(".view_provider", issuer: @api_key_role.provider.issuer), profile_oidc_provider_path(@api_key_role.provider) %> →
  </div>
  <h3 class="t-list__heading"><%= OIDC::ApiKeyRole.human_attribute_name(:api_key_permissions) %></h3>
  <div class="push--s">
    <%= render partial: "oidc/api_key_permissions/api_key_permissions", object: @api_key_role.api_key_permissions %>
  </div>
  <h3 class="t-list__heading"><%= OIDC::ApiKeyRole.human_attribute_name(:access_policy) %></h3>
  <div class="push--s">
    <%= render partial: "oidc/access_policies/access_policy", object: @api_key_role.access_policy %>
  </div>

  <% unless @api_key_role.deleted_at? %>
    <%= button_to t(".edit_role"), edit_profile_oidc_api_key_role_path(@api_key_role.token), method: "get", class: "form__submit" %>
    <%= button_to t(".delete_role"), profile_oidc_api_key_role_path(@api_key_role.token), method: "delete", class: "form__submit", data: { confirm: t(".confirm_delete") } %>
  <% end %>
  <h3 class="t-list__heading"><%= OIDC::ApiKeyRole.human_attribute_name(:id_tokens) %></h3>
  <div class="push--s">
    <header class="gems__header push--s">
      <p class="gems__meter l-mb-0"><%= page_entries_info(@id_tokens) %></p>
    </header>
    <% if @id_tokens.present? %>
      <%= render OIDC::IdToken::TableComponent.new(id_tokens: @id_tokens) %>
    <% end %>
  </div>
</div>
